package com.xnyzc.lhy.order.controller.capi.home;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.order.IOrderExpressService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  首页相关
 * </p>
 *
 */
@RestController
@RequestMapping(value = "/oa/homepage")
public class HomePageController {

    @Autowired
    private IOrderExpressService orderExpressService;

    /**
     * 乘客端拉取页面数据
     * @return
     */
    @ApiOperation(value = "拉取页面数据", notes = "拉取页面数据")
    @GetMapping(value = "/pullPageData")
    public Rv pullPageData() {
        Long userId = TokenUtil.getTokenUserId();
        if (CheckUtil.objIsEmpty(userId)){
            throw PangException.create(EErrorCode.tokenExpire);
        }
//        String tag = TokenUtil.getTag();
//        if (StringUtils.isEmpty(tag)){
//            throw PangException.create(EErrorCode.missingAuthArgs);
//        }
        return orderExpressService.pullPageData(userId);
    }

}
